using System;
using System.Collections;
using OracleInternal.Common;

namespace Oracle.ManagedDataAccess.Client
{
	internal static class OracleTypeMapper
	{
		public static Hashtable m_OraToOraDb;

		public static Hashtable m_OraToNET;

		internal const string VARCHAR2 = "VARCHAR2";

		internal const string NVARCHAR2 = "NVARCHAR2";

		internal const string NUMBER = "NUMBER";

		internal const string LONG = "LONG";

		internal const string DATE = "DATE";

		internal const string RAW = "RAW";

		internal const string LONG_RAW = "LONG RAW";

		internal const string ROWID = "ROWID";

		internal const string CHAR = "CHAR";

		internal const string NCHAR = "NCHAR";

		internal const string BINARY_FLOAT = "BINARY_FLOAT";

		internal const string BINARY_DOUBLE = "BINARY_DOUBLE";

		internal const string UDT = "USERDEFINEDTYPE";

		internal const string REF = "REF";

		internal const string CLOB = "CLOB";

		internal const string NCLOB = "NCLOB";

		internal const string BLOB = "BLOB";

		internal const string BFILE = "BFILE";

		internal const string TIMESTAMP = "TIMESTAMP";

		internal const string TIMESTAMP_WITH_TIME_ZONE = "TIMESTAMP WITH TIME ZONE";

		internal const string INTERVAL_YEAR_TO_MONTH = "INTERVAL YEAR TO MONTH";

		internal const string INTERVAL_DAY_TO_SECOND = "INTERVAL DAY TO SECOND";

		internal const string UROWID = "UROWID";

		internal const string TIMESTAMP_WITH_LOCAL_TIME_ZONE = "TIMESTAMP WITH LOCAL TIME ZONE";

		internal const string XML = "XMLTYPE";

		internal const int ORACLEDBTYPE_MINVAL = 101;

		internal const int ORACLEDBTYPE_ENUM_COUNT = 34;

		internal static string[] m_OraDbToOraNative;

		static OracleTypeMapper()
		{
			m_OraToOraDb = new Hashtable(19);
			m_OraToNET = new Hashtable(19);
			m_OraDbToOraNative = new string[34]
			{
				"BFILE",
				"BLOB",
				"NUMBER",
				"CHAR",
				"CLOB",
				"DATE",
				"NUMBER",
				"NUMBER",
				"LONG",
				"LONG RAW",
				"NUMBER",
				"NUMBER",
				"NUMBER",
				"INTERVAL DAY TO SECOND",
				"INTERVAL YEAR TO MONTH",
				"NCLOB",
				"NCHAR",
				string.Empty,
				"NVARCHAR2",
				"RAW",
				string.Empty,
				"NUMBER",
				"TIMESTAMP",
				"TIMESTAMP WITH LOCAL TIME ZONE",
				"TIMESTAMP WITH TIME ZONE",
				"VARCHAR2",
				"XMLTYPE",
				string.Empty,
				string.Empty,
				string.Empty,
				string.Empty,
				"BINARY_DOUBLE",
				"BINARY_FLOAT",
				string.Empty
			};
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleTypeMapper, OracleTraceFuncName.cctor);
			}
			try
			{
				m_OraToNET.Add(OraType.ORA_CHAR, typeof(string));
				m_OraToNET.Add(OraType.ORA_CHARN, typeof(string));
				m_OraToNET.Add(OraType.ORA_DATE, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_INTERVAL_DS, typeof(TimeSpan));
				m_OraToNET.Add(OraType.ORA_INTERVAL_DS_DTY, typeof(TimeSpan));
				m_OraToNET.Add(OraType.ORA_INTERVAL_YM, typeof(long));
				m_OraToNET.Add(OraType.ORA_INTERVAL_YM_DTY, typeof(long));
				m_OraToNET.Add(OraType.ORA_LONG, typeof(string));
				m_OraToNET.Add(OraType.ORA_LONGRAW, typeof(byte[]));
				m_OraToNET.Add(OraType.ORA_NUMBER, typeof(decimal));
				m_OraToNET.Add(OraType.ORA_OCIBFileLocator, typeof(byte[]));
				m_OraToNET.Add(OraType.ORA_OCIBLobLocator, typeof(byte[]));
				m_OraToNET.Add(OraType.ORA_OCICLobLocator, typeof(string));
				m_OraToNET.Add(OraType.ORA_OCIJSON, typeof(string));
				m_OraToNET.Add(OraType.ORA_UROWID, typeof(string));
				m_OraToNET.Add(OraType.ORA_ROWID, typeof(string));
				m_OraToNET.Add(OraType.ORA_RAW, typeof(byte[]));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP_DTY, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP_TZ, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP_TZ_DTY, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP_LTZ, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_TIMESTAMP_LTZ_DTY, typeof(DateTime));
				m_OraToNET.Add(OraType.ORA_INTY, typeof(string));
				m_OraToNET.Add(OraType.ORA_IBFLOAT, typeof(float));
				m_OraToNET.Add(OraType.ORA_IBDOUBLE, typeof(double));
				m_OraToNET.Add(OraType.ORA_BFLOAT, typeof(float));
				m_OraToNET.Add(OraType.ORA_BDOUBLE, typeof(double));
				m_OraToOraDb.Add(OraType.ORA_CHAR, OracleDbType.Char);
				m_OraToOraDb.Add(OraType.ORA_CHARN, OracleDbType.Varchar2);
				m_OraToOraDb.Add(OraType.ORA_DATE, OracleDbType.Date);
				m_OraToOraDb.Add(OraType.ORA_INTERVAL_YM, OracleDbType.IntervalYM);
				m_OraToOraDb.Add(OraType.ORA_INTERVAL_YM_DTY, OracleDbType.IntervalYM);
				m_OraToOraDb.Add(OraType.ORA_INTERVAL_DS, OracleDbType.IntervalDS);
				m_OraToOraDb.Add(OraType.ORA_INTERVAL_DS_DTY, OracleDbType.IntervalDS);
				m_OraToOraDb.Add(OraType.ORA_LONG, OracleDbType.Long);
				m_OraToOraDb.Add(OraType.ORA_LONGRAW, OracleDbType.LongRaw);
				m_OraToOraDb.Add(OraType.ORA_NUMBER, OracleDbType.Decimal);
				m_OraToOraDb.Add(OraType.ORA_OCIBFileLocator, OracleDbType.BFile);
				m_OraToOraDb.Add(OraType.ORA_OCIBLobLocator, OracleDbType.Blob);
				m_OraToOraDb.Add(OraType.ORA_OCICLobLocator, OracleDbType.Clob);
				m_OraToOraDb.Add(OraType.ORA_OCIJSON, OracleDbType.Json);
				m_OraToOraDb.Add(OraType.ORA_UROWID, OracleDbType.Varchar2);
				m_OraToOraDb.Add(OraType.ORA_ROWID, OracleDbType.Varchar2);
				m_OraToOraDb.Add(OraType.ORA_RAW, OracleDbType.Raw);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP, OracleDbType.TimeStamp);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP_DTY, OracleDbType.TimeStamp);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP_TZ, OracleDbType.TimeStampTZ);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP_TZ_DTY, OracleDbType.TimeStampTZ);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP_LTZ, OracleDbType.TimeStampLTZ);
				m_OraToOraDb.Add(OraType.ORA_TIMESTAMP_LTZ_DTY, OracleDbType.TimeStampLTZ);
				m_OraToOraDb.Add(OraType.ORA_INTY, OracleDbType.XmlType);
				m_OraToOraDb.Add(OraType.ORA_IBFLOAT, OracleDbType.BinaryFloat);
				m_OraToOraDb.Add(OraType.ORA_IBDOUBLE, OracleDbType.BinaryDouble);
				m_OraToOraDb.Add(OraType.ORA_BFLOAT, OracleDbType.BinaryFloat);
				m_OraToOraDb.Add(OraType.ORA_BDOUBLE, OracleDbType.BinaryDouble);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleTypeMapper, OracleTraceFuncName.cctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleTypeMapper, OracleTraceFuncName.cctor);
				}
			}
		}
	}
}
